package com.ashley.day_0607;

public class YangHuiTest {

	public static void main(String[] args) {
		int yangHui[][] = new int[10][];// 声明并初始化二维数组
		for (int i = 0; i < yangHui.length; i++) {
			yangHui[i] = new int[i + 1];// 给二维数组的各元素赋值，结果为0且第n行有n+1个元素
			yangHui[i][0] = yangHui[i][i] = 1;// 给二维数组每一行的首位元素赋值，结果为1
			if (i > 1) {
				for (int j = 1; j < yangHui[i].length - 1; j++) {
					yangHui[i][j] = yangHui[i - 1][j] + yangHui[i - 1][j - 1];// 给二维数组的非首位元素赋值
				}

			}
		}
		for (int i = 0; i < yangHui.length; i++) {// 遍历二维数组
			for (int j = 0; j < yangHui[i].length; j++) {
				System.out.print(yangHui[i][j] + "\t");
			}
			System.out.println();
		}

	}

}
